package com.kede.domain;

import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;

/**
* @description /
* @author Pr.li
* @date 2023-04-22
**/
@Entity
@Data
@Table(name="resource_area_map")
@IdClass(ResourceAreaMap.class)
@NoArgsConstructor
public class ResourceAreaMap implements Serializable {
    /**
    * 资源id
    */
    @ApiModelProperty(value = "资源id")
    @Id
    @Column(name = "`resource_id`")
    private Integer resourceId;
    /**
    * 区/县编码
    */
    @ApiModelProperty(value = "区/县编码")
    @Id
    @Column(name = "`area_id`")
    private Integer areaId;

    public ResourceAreaMap(Integer resourceId,Integer areaId){
        this.resourceId = resourceId;
        this.areaId = areaId;
    }
    public void copy(ResourceAreaMap source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
